package com.ostrich.module_home.discovery.adapter

import com.chad.library.adapter.base.BaseProviderMultiAdapter
import com.ostrich.module_home.R
import com.ostrich.module_home.discovery.adapter.provider.*
import com.ostrich.module_home.discovery.entity.DiscoveryEntity

/**
 * @Author : yaotianxue
 * @Time : On 2023/10/30 15:02
 * @Description : DiscoveryAdapter
 */
class DiscoveryAdapter:BaseProviderMultiAdapter<DiscoveryEntity>(){
    init {
        addItemProvider(TextCardProvider(DiscoveryItemType.TEXT_CARD_VIEW, R.layout.home_item_discovery_title_left_right_view))
        addItemProvider(VideoSmallCardProvider(DiscoveryItemType.VIDEO_CARD_VIEW, R.layout.home_item_discovery_video_card_view))
        addItemProvider(BriefCardProvider(DiscoveryItemType.BRIEF_CARD_VIEW, R.layout.home_item_brief_card_view))
        addItemProvider(SubjectCardProvider(DiscoveryItemType.SUBJECT_CARD_VIEW, R.layout.home_item_discovery_subject_card_view))
        addItemProvider(CategoryCardProvider(DiscoveryItemType.CATEGORY_CARD_VIEW, R.layout.home_item_discovery_category_card_view))
        addItemProvider(TopBannerProvider(DiscoveryItemType.TOP_BANNER_VIEW, R.layout.home_item_top_banner_view))

        addItemProvider(EmptyProvider(DiscoveryItemType.EMPTY_VIEW, R.layout.home_item_empty))
    }

    override fun getItemType(data: List<DiscoveryEntity>, position: Int): Int {
        return when(data[position].type){
            "textCard" -> DiscoveryItemType.TEXT_CARD_VIEW
            "videoSmallCard" -> DiscoveryItemType.VIDEO_CARD_VIEW
            "briefCard" -> DiscoveryItemType.BRIEF_CARD_VIEW
            "columnCardList" -> DiscoveryItemType.SUBJECT_CARD_VIEW
            "specialSquareCardCollection" -> DiscoveryItemType.CATEGORY_CARD_VIEW
            "horizontalScrollCard" -> DiscoveryItemType.TOP_BANNER_VIEW
            else -> DiscoveryItemType.EMPTY_VIEW

        }
    }
}